<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    
    <title data-i18n="optionsPageTitle">表单数据保存 - 设置</title>
    <link rel="stylesheet" href="css/styles.css">
    <style>
        :root {
            --primary: #2563eb;
            --primary-hover: #1d4ed8;
            --danger: #dc2626;
            --danger-hover: #b91c1c;
            --success: #10b981;
            --success-hover: #059669;
            --border-color: #e5e7eb;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f3f4f6;
            min-height: 100vh;
            color: #1f2937;
        }

        .container {
            max-width: 800px;
            margin: 0 auto;
            padding: 2rem 1rem;
        }

        .tabs {
            display: flex;
            gap: 1px;
            background-color: white;
            padding: 0;
            margin-bottom: 2rem;
            border-radius: 12px;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
            overflow: hidden;
        }

        .tab-button {
            flex: 1;
            padding: 1rem;
            border: none;
            background: none;
            font-size: 0.95rem;
            font-weight: 500;
            color: #6b7280;
            cursor: pointer;
            position: relative;
        }

        .tab-button:hover {
            color: var(--primary);
            background-color: #f8fafc;
        }

        .tab-button.active {
            color: var(--primary);
            background-color: #f8fafc;
        }

        .tab-button.active::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            height: 2px;
            background-color: var(--primary);
        }

        .tab-content {
            display: none;
        }

        .tab-content.active {
            display: block;
        }

        .card {
            background: white;
            border-radius: 12px;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
            padding: 1.5rem;
            margin-bottom: 1.5rem;
            transition: box-shadow 0.2s;
        }

        .card:hover {
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        .section-header {
            margin-bottom: 2rem;
            padding-bottom: 1rem;
            border-bottom: 2px solid var(--border-color);
        }

        .section-title {
            font-size: 1.5rem;
            font-weight: 600;
            color: #111827;
            margin: 0 0 0.5rem 0;
        }

        .section-description {
            color: #6b7280;
            font-size: 0.975rem;
        }

        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 0.75rem 1.5rem;
            border-radius: 8px;
            font-weight: 500;
            /* transition: all 0.2s; */
            border: none;
            cursor: pointer;
            width: 100%;
            font-size: 0.95rem;
        }

        .btn-primary {
            background: var(--primary);
            color: white;
        }

        .btn-primary:hover {
            background: var(--primary-hover);
        }

        .btn-success {
            background: var(--success);
            color: white;
        }

        .btn-success:hover {
            background: var(--success-hover);
        }

        .btn-danger {
            background: var(--danger);
            color: white;
        }

        .btn-danger:hover {
            background: var(--danger-hover);
        }

        .info-box {
            padding: 1rem;
            border-radius: 8px;
            margin: 1rem 0;
        }

        .info-box.warning {
            background-color: #fff7ed;
            color: #c2410c;
            border: 1px solid #fed7aa;
        }

        .info-box.info {
            background-color: #eff6ff;
            color: #1e40af;
            border: 1px solid #bfdbfe;
        }

        .info-box.danger {
            background-color: #fef2f2;
            color: #991b1b;
            border: 1px solid #fecaca;
        }

        .checkbox-wrapper {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            margin: 1rem 0;
        }

        .checkbox-wrapper input[type="checkbox"] {
            width: 1.2rem;
            height: 1.2rem;
            border-radius: 4px;
        }

        #status {
            position: fixed;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            padding: 0.75rem 1.5rem;
            border-radius: 8px;
            color: white;
            opacity: 0;
            z-index: 1000;
            transition: all 0.3s;
        }

        #status.show {
            opacity: 1;
            transform: translateX(-50%) translateY(0);
        }

        @media (max-width: 640px) {
            .container {
                padding: 1rem;
            }
            
            .card {
                padding: 1rem;
            }
            
            .section-title {
                font-size: 1.25rem;
            }

            .tabs {
                flex-direction: column;
            }

            .tab-button.active::after {
                width: 2px;
                height: auto;
                top: 0;
                bottom: 0;
                right: 0;
                left: auto;
            }
        }
    </style>
</head>

<body>
    <div class="container">
        <!-- 标签页导航 -->
        <div class="tabs">
            <button class="tab-button active" data-tab="websites" data-i18n="websiteManagement">网站管理</button>
            <button class="tab-button" data-tab="settings" data-i18n="generalSettings">通用设置</button>
            <button class="tab-button" data-tab="datasets" data-i18n="datasetManagement">数据集管理</button>
            <button class="tab-button" data-tab="data" data-i18n="dataManagement">数据管理</button>
        </div>

        <!-- 网站管理标签页 -->
        <div id="websites" class="tab-content active">
            <div class="card">
                <div class="mb-6">
                    <div class="info-box info">
                        <p data-i18n="websiteManagementDesc">在下面添加您想要启用表单数据保存功能的网页路径。只要网页地址包含该路径，就会启用功能。</p>
                        <p class="text-sm mt-2" data-i18n="websiteManagementExample">示例: /video/ 或 bilibili.com/video</p>
                    </div>
                </div>

                <div id="urlList" class="space-y-4 mb-6"></div>

                <button id="addUrl" class="btn btn-success" data-i18n="addWebsite">
                    添加网站
                </button>
            </div>
        </div>

        <!-- 通用设置标签页 -->
        <div id="settings" class="tab-content">
            <div class="card">
                <h3 class="text-lg font-medium mb-4" data-i18n="generalSettings">通用设置</h3>

                <!-- 日志设置 -->
                <div class="checkbox-wrapper">
                    <input type="checkbox" id="enableLogging" class="rounded">
                    <label for="enableLogging" data-i18n="enableDebugLogging">启用控制台日志</label>
                </div>
                <p class="text-sm text-gray-500 mt-2" data-i18n="loggingDescription">启用后将在浏览器控制台打印调试信息</p>
            </div>
        </div>

        <!-- 数据集管理标签页 -->
        <div id="datasets" class="tab-content">
            <div class="card">
                <div class="section-header">
                    <h2 class="section-title" data-i18n="datasetManagementTitle">数据集管理</h2>
                    <p class="section-description" data-i18n="datasetManagementDesc">管理已保存的表单数据集，可以查看、删除或设置默认加载的数据集。</p>
                </div>

                <div class="info-box info mb-4">
                    <p data-i18n="datasetUsageInfo">选择一个数据集作为默认加载项，或选择"不使用数据集"以使用实时保存的数据。</p>
                </div>

                <div id="datasetList" class="space-y-4">
                    <!-- 数据集列表将通过 JavaScript 动态添加 -->
                </div>
            </div>
        </div>

        <!-- 数据管理标签页 -->
        <div id="data" class="tab-content">
            <!-- 数据删除部分 -->
            <div class="card">
                <div class="info-box danger mb-4">
                    <p class="font-medium" data-i18n="dangerZone">危险操作区</p>
                    <p class="text-sm mt-2" data-i18n="deleteAllDataWarning">删除所有已保存的表单数据，此操作无法撤销。</p>
                </div>
                <button id="clearAllData" class="btn btn-danger" data-i18n="deleteAllData">
                    删除所有数据
                </button>
            </div>

            <!-- 数据备份部分 -->
            <div class="card">
                <div class="space-y-6">
                    <div>
                        <button id="exportData" class="btn btn-primary mb-2" data-i18n="exportData">
                            导出数据
                        </button>
                        <p class="text-sm text-gray-600" data-i18n="exportDataDesc">导出所有保存的表单数据和设置到本地文件</p>
                    </div>
                    
                    <div class="border-t pt-6">
                        <input type="file" id="importFile" accept=".json" class="hidden">
                        <button id="importData" class="btn btn-success mb-2" data-i18n="importData">
                            导入数据
                        </button>
                        <p class="text-sm text-gray-600" data-i18n="importDataDesc">从本地文件导入之前导出的数据</p>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div id="status"></div>
    <script src="./libs/lucide.js"></script>
    <script src="options.js"></script>


</body>
</html>